package com.xhdd;

import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.text.Html;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.TextView;

import com.xhdd.bean.Chapter;
import com.xhdd.manager.BookDataFetch;

public class MainActivity extends Activity {

	TextView content;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		content = (TextView) findViewById(R.id.content);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}

	public void btn_Click(View view) {
		new Thread() {
			String toShowContent;
			public void run() {
				Log.i("test", "----------------");
				BookDataFetch bookDataFetch = new BookDataFetch(MainActivity.this);
			
				List<Chapter> list = bookDataFetch.getAllChapters();
				for (Chapter c : list) {
					Log.i("test",
							"----------------" + c.getTitle() + "  "
									+ c.getUrl()+" "+c.getIndex());
				}
//				 toShowContent = bookDataFetch
//						.getCharpterContentByUrl(list.get(0));
				runOnUiThread(new Runnable() {

					@Override
					public void run() {
						content.setText(Html.fromHtml(toShowContent));
					}
				});
			};
		}.start();
	}
}
